package com.gsn.poker.play;

import aurelienribon.tweenengine.Tween;
import aurelienribon.tweenengine.equations.Linear;

import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.gsn.desktop.engine.ActorUtility;
import com.gsn.engine.gdx.GsnRotationImage;
import com.gsn.engine.myplay.GsnGame;
import com.gsn.engine.tween.ActorAccessor;
import com.gsn.engine.tween.GsnTween;
import com.gsn.poker.asset.PokerTexture;
import com.gsn.poker.game.MyPoker;
import com.gsn.poker.logic.CardGroupLogic;

public class WinEffGroup extends Group {
	public WinEffGroup(int type, CardGroupLogic bobai) {
		transform = GsnGame.transform;
		Image bg = new Image(PokerTexture.inst().thangXiTo);
		this.addActor(bg);
		this.width = bg.width;
		this.height = bg.height;
		Image info = null;
		CardGroup bobaiGroup = CardGroup.createTemplate(bobai);

		switch (type) {
		case CardGroupLogic.eTHAU:
			info = new Image(PokerTexture.inst().chuMau);
			bobaiGroup = CardGroup.createTemplate(new CardGroupLogic(51));
			break;
		case CardGroupLogic.eDOI:
			info = new Image(PokerTexture.inst().chuDoi);
			bobaiGroup = CardGroup.createTemplate(new CardGroupLogic(42, 43));
			break;
		case CardGroupLogic.eTHU:
			info = new Image(PokerTexture.inst().chuThu);
			bobaiGroup = CardGroup.createTemplate(new CardGroupLogic(42, 43, 46, 47));
			break;
		case CardGroupLogic.eSAM_CO:
			info = new Image(PokerTexture.inst().chuSamCo);
			bobaiGroup = CardGroup.createTemplate(new CardGroupLogic(46, 44, 45));
			break;
		case CardGroupLogic.eSANH:
			info = new Image(PokerTexture.inst().chuSanh);
			bobaiGroup = CardGroup.createTemplate(new CardGroupLogic(19, 20, 24, 30, 33));
			break;
		case CardGroupLogic.eTHUNG:
			info = new Image(PokerTexture.inst().chuThung);
			bobaiGroup = CardGroup.createTemplate(new CardGroupLogic(16, 20, 32, 44, 48));
			break;
		case CardGroupLogic.eCU_LU:
			info = new Image(PokerTexture.inst().chuCulu);
			bobaiGroup = CardGroup.createTemplate(new CardGroupLogic(2, 3, 0, 46, 47));
			break;
		case CardGroupLogic.eTU_QUY:
			info = new Image(PokerTexture.inst().chuTuQuy);
			bobaiGroup = CardGroup.createTemplate(bobai);
			break;
		case CardGroupLogic.eTHUNG_PHA_SANH:
			info = new Image(PokerTexture.inst().chuThungPhaSanhEffect);
			bobaiGroup = CardGroup.createTemplate(bobai);
			break;

		}

		bobaiGroup.packCard();
		bobaiGroup.x = this.width * 0.2f;
		bobaiGroup.y = this.height * 0.5f - bobaiGroup.height / 2;
		// ActorUtility.setRatio(bobaiGroup, 0.5f, 0.5f, this.width * 0.5f,
		// height * 0.5f);
		// info = new Image(PokerTexture.inst().thungPhaSanhEffect);
		ActorUtility.setRatio(info, 0.5f, -1f, width / 2, 0);

		GsnRotationImage rotation = new GsnRotationImage(PokerTexture.inst().xoayThungPhaSanh);

		rotation.setCenter(width / 2, height / 2);

		Tween.to(rotation, ActorAccessor.ROTATION_CENTER, 2f).target(360).ease(Linear.INOUT).repeat(10, 0).start(MyPoker.game.tweenManger);

		addActor(rotation);
		addActor(bobaiGroup);
		addActor(info);
	}
}
